<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <link type="text/css" rel="stylesheet" th:href="@{/static/qrcodes.css}" />
    <link type="text/css" rel="stylesheet" th:href="@{/static/bootstrap-3.3.7/css/bootstrap.css}" />
    <title>修改个人信息</title>
    <script th:src="@{/static/jquery3.js}"></script>
    <script th:src="@{/static/jquery-form.js}"></script>
    <script type="text/javascript">
        $(document).ready(function() {

            //为表单的必填文本框添加提示信息（选择form中的所有后代input元素）
            $("#userForm :input.required").each(function () {
                //通过jquery api：$("HTML字符串") 创建jquery对象
                var $required = $("<span><strong style='color:red;'>*</strong></span>");
                //添加到this对象的父级对象下
                $(this).parent().append($required);
            });

            $("#userFormSubmitButton").click(function () {
                var valid = true;
                $("#userForm :input.required").each(function () {
                    var val = $.trim($(this).val());
                    if (val.length == 0){
                        label = $(this).prev().html();
                        alert(label+"不能为空！");
                        $(this).focus();
                        valid = false;
                        return false;
                    }
                });
                if(!valid) return false;

                if(!(/^1[34578]\d{9}$/.test($("#phone").val()))){
                    alert("请输入合法的手机号！");
                    return false;
                }
                var emailRe = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
                if (!emailRe.test($("#email").val())) {
                    alert("请输入合法的邮箱地址！");
                    return false;
                }
                if(valid){
                    $("#userForm").submit();
                }

            });



        });
    </script>
</head>
<body style="font-size: 13px;">
<div class = "pg_header">
    <a class="pg_dl" id="i77" th:align="center">修改资料</a>
</div>
<form th:action="@{/user/update}" method="post" id="userForm">
    <div class="left"></div>
    <div class="pg_body" style="margin-top: 60px">
  <!--  <div>
        &lt;!&ndash;/*@thymesVar id="error" type=""*/&ndash;&gt;
        <span id="basic-addon0">&nbsp;</span>
        <span style="font-size: 12px;color: red" th:text="${error}" aria-describedby="basic-addon0"></span>
        <br />
    </div>-->
        <div class="menu">
            <!--/*@thymesVar id="error" type=""*/-->
            <span id="basic-addon0">&nbsp;</span>
        </div>
        <div class="kong" style="width:300px">

            <span style="font-size: 12px;color: red" th:text="${error}" aria-describedby="basic-addon0"></span>

            <br />
        </div>
        <div class="menu">
        <span id="basic-addon1">旧密码</span>
        </div>
        <div class="kong" style="width:300px">
        <input class="required" id="oldUserPwd" name="oldUserPwd" type="password" placeholder="旧密码" aria-describedby="basic-addon1" />
        </div>

        <div class="menu">
        <span id="basic-addon2">新密码</span>
        </div>
        <div class="kong" style="width:300px">
        <input class="required" id="userPwd" name="userPwd" type="password" placeholder="新密码" aria-describedby="basic-addon1" />
        </div>

    <br />
        <div class="menu">
        <span id="basic-addon3">手机号</span>
        </div>
        <div class="kong" style="width:300px">
        <input class="required" id="phone" name="phone" th:value="${user.phone}" type="text" placeholder="手机号" aria-describedby="basic-addon2" />
        </div>

    <br />
        <div class="menu">
        <span id="basic-addon4">邮箱</span>
        </div>
        <div class="kong" style="width:300px">
        <input class="required" id="email" name="email" th:value="${user.email}" type="text" placeholder="email" aria-describedby="basic-addon3" />
        </div>

        <div class="menu">
        <span id="basic-addon5">注册时间</span>
        </div>
        <div class="kong" style="width:300px">
        <span th:text="${#dates.format(user.addTime, 'yyyy-MM-dd HH:mm:ss')}"></span>
        </div>

        <div class="menu">
        <span id="basic-addon6">修改时间</span>
        </div>
        <div class="kong" style="width:300px">
        <span th:text="${#dates.format(user.modifyTime, 'yyyy-MM-dd HH:mm:ss')}"></span>
        </div>

        <div class="menu"></div>
        <div class="kong" style="margin-top: 10px">
        <button  type="button" id="userFormSubmitButton" style="width:110px;height:50px">修 改</button>
        </div>
    </div>
</form>

</body>
</html>